import './AddFormData.scss'

import { FormItemData } from '../../Config/FormItemData'
import { AddProcessForm, ProcessItemForm } from '../../Config/FormAdd'
import { FormTempMapping } from '../../Utils/FormTemp'

import { Marsd3dConfig } from '../../Config/Mars3dConfig'
import { CommonConfig } from '../../Config/CommonConfig'
import { StartConfig } from '../../Config/StartConfig'
import { ProcessConfig } from '../../Config/ProcessConfig'
import { LayoutConfig } from '../../Config/LayoutConfig'



const AddFormData = ({ data, Off }) => {
    const { type, AddEvnet, Initial, config, onCallBack } = data
    AddEvnet.useSubscription(val => {
        const { type, data } = val
        if (type === 'closeForm') Off()
    })

    return (
        <div className='AddFormData'>
            {type === 'AddProcessForm' && <FormTempMapping formItem={AddProcessForm} FORMEVENT={AddEvnet} />}
            {type === 'ProcessItemForm' && <FormTempMapping formItem={ProcessItemForm} FORMEVENT={AddEvnet} Initial={Initial} />}
            {type === 'dailyQuizOption' && <FormTempMapping formItem={FormItemData['dailyQuizOption']} FORMEVENT={AddEvnet} Initial={Initial} />}
            {type === 'AddElement' && <FormTempMapping formItem={Marsd3dConfig['ElementListFields']} FORMEVENT={AddEvnet} Initial={Initial} />}
            {type === 'ContractComparison' && <FormTempMapping formItem={CommonConfig.ContractComparison} FORMEVENT={AddEvnet} />}

            {type === 'AddStartRouter' && <FormTempMapping formItem={StartConfig.RouterConfigData} FORMEVENT={AddEvnet} Initial={Initial} />}
            {type === 'AddStartTop' && <FormTempMapping formItem={StartConfig.TopConfigData} FORMEVENT={AddEvnet} Initial={Initial} NotLoading />}
            {type === 'AddStartWindow' && <FormTempMapping formItem={StartConfig.StastSmallWindow} FORMEVENT={AddEvnet} Initial={Initial} NotLoading />}
            {type === 'AddStartScroll' && <FormTempMapping formItem={StartConfig.StartScrollConfig} FORMEVENT={AddEvnet} Initial={Initial} NotLoading />}
            {type === 'AddStartNav' && <FormTempMapping formItem={StartConfig.StartNavConfig} FORMEVENT={AddEvnet} Initial={Initial} NotLoading />}


            {type === 'StartPadding' &&
                <FormTempMapping formItem={StartConfig.StartPagePadding} FORMEVENT={AddEvnet} Initial={Initial} NotLoading onCallBack={onCallBack} />
            }
            {type === 'StartApiUrl' &&
                <FormTempMapping formItem={StartConfig.StartPageApiUrl} FORMEVENT={AddEvnet} Initial={Initial} NotLoading onCallBack={onCallBack} />
            }

            {type === 'AddProcessItem' && <FormTempMapping formItem={ProcessConfig.ListContent} FORMEVENT={AddEvnet} Initial={Initial} />}
            {type === 'AddProcessBack' && <FormTempMapping formItem={ProcessConfig.X6BackConfig} FORMEVENT={AddEvnet} Initial={Initial} NotLoading />}
            {type === 'AddProcessNode' && <FormTempMapping formItem={ProcessConfig.NodeConfig} FORMEVENT={AddEvnet} Initial={Initial} />}


            {type === 'LayoutSetModel' &&
                <FormTempMapping formItem={LayoutConfig.modelConfig} FORMEVENT={AddEvnet} Initial={Initial} NotLoading onCallBack={onCallBack} />
            }
            {type === 'LayoutSetNav' &&
                <FormTempMapping formItem={LayoutConfig.navConfig} FORMEVENT={AddEvnet} Initial={Initial} NotLoading onCallBack={onCallBack} />
            }

            {type === 'SetTemplateConfig' &&
                <FormTempMapping formItem={LayoutConfig[config]} FORMEVENT={AddEvnet} Initial={Initial} NotLoading onCallBack={onCallBack} />
            }
            {type === 'AddFence' && <FormTempMapping formItem={Marsd3dConfig.FenceConfig} FORMEVENT={AddEvnet} Initial={Initial} onCallBack={onCallBack} />}

        </div>
    );
};

export default AddFormData;